layui.config({
    base: '/lib/layuiadmin/' //静态资源所在路径
}).extend({
    index: 'lib/index' //主入口模块
}).use(['index'], function() {
    var form = layui.form,
        $ = layui.$;

    form.verify({
        pass:[/^[\S]{6,12}$/,"密码必须6到12位，且不能出现空格"],
        // 验证二次输入是否正确
        repass: function(value) {
            if(value!==$("#LAY_password").val()){
                return"两次密码输入不一致"
            }
        }
    }).on('submit(setmypass)', function(data) {
        console.log(data.field);
        $.ajax({
            url: '/system/user/changepsd',
            type: 'PUT',
            async: true,
            data: data.field,
            success: function(res) {
                if(res.code == 10000) {
                    layer.msg(res.message, {icon: 1});
                    setTimeout(function () {
                        top.location.href = '/logout';
                    }, 3000)
                } else {
                    layer.msg(res.message, {icon: 5});
                }
            }
        })
    })
});